const addressModel = require("../models/address_model")

const Result = require("../beans/result")

function AddAddresslist(userid,callback) {
    addressModel.getAddressList(userid,(err, data) => {
        if (err) {
            callback(new Result(err, data, "已添加地址数据", 200))
        } else {

            callback(new Result(null, data, "添加地址数据成功", 200))
        }
    })
}
function getAddresslist(userid,callback) {
    addressModel.getAddressList(userid,(err, data) => {
        if (err) {
            callback(new Result(err, data, "查询用户地址数据失败", 401))
        } else {

            callback(new Result(null, data, "查询用户地址数据成功", 200))
        }
    })
}
function putAddresslist(userid,callback) {
    addressModel.getAddressList(userid,(err, data) => {
        if (err) {
            callback(new Result(err, data, "修改用户地址数据失败", 401))
        } else {

            callback(new Result(null, data, "修改用户地址数据成功", 200))
        }
    })
}
function deleteAddresslist(userid,callback) {
    addressModel.getAddressList(userid,(err, data) => {
        if (err) {
            callback(new Result(err, data, "删除用户地址数据失败", 401))
        } else {

            callback(new Result(null, data, "删除用户地址数据成功", 200))
        }
    })
}
module.exports = {
    AddAddresslist,
    getAddresslist,
    putAddresslist,
    deleteAddresslist
}